#include <iostream>
#include <fstream>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <functional>
#include <boost/bind.hpp>
#include <boost/timer.hpp>
#include <boost/mem_fn.hpp>
#include <boost/shared_ptr.hpp>

using namespace std;

struct A
{
        A(int i):a(i){}
	int a;
	void print()
	{
		cout<<a<<" ";
	}
};

int main(int atrgc, char** argv)
{
	vector<A> V;
	const int size = 10;
	for(int i=0;i<size;++i)
		V.push_back(A(i));
	for_each( V.begin(), V.end(), boost::mem_fn(&A::print) );
	cout<<endl;
	
	typedef  boost::shared_ptr<A> SAP;
	vector<SAP> V1;
	for(int i=0;i<size;++i)
		V1.push_back( SAP( new A(i) ) );
	for_each( V1.begin(), V1.end(), boost::mem_fn(&A::print) );
	cout<<endl;

	for_each( V.begin(), V.end(), boost::bind(&A::print, _1) );
	cout<<endl;

	for_each( V1.begin(), V1.end(), boost::bind(&A::print, _1) );
	cout<<endl;

	return 0;
}
